const ble = {
  namespaced: true,
  state: {
    deviceInfo: null, //设备信息
    bleStatus: 2, // 0：初始未连接状态 1：连接中 2：已连接 3: 连接超时
    systemInfo: null,
    charactValueChangeRes: null,
    modeSelection: "", //模式选择
    sourceSelection: "", //音源选择
    SoundChoice: "", //音效选择
    soundField: "", //音场选择
    masterVolume: 0, //总音量
    ValDenoise: 0, //降噪
    originalCarAudio: 0, //原车音源
    HicarCarAudio:0,//Hicar音源
    AUXCarAudio:0,//AUX音源
    USBCarAudio:0,//USB音源
    soundFieldback:0,//音场前后
    soundFieldLeftRight:0,//音场左右
    loudspeaker:'00',//喇叭位置
    ic_hornActive: false, //喇叭设置 前左
    ic_beforeActive: false, //喇叭设置 前右
    ic_hornActiveTow: false, //喇叭设置 后左
    ic_beforeActiveTow: false, //喇叭设置 后右
    hornDelay:0,//喇叭延迟
    SpeakerVolume:0,//喇叭音量
    SpeakerNumber:"00",//喇叭静音数据
    SpeakerMute:null,//喇叭静音 false为反向   true正向 
    SpeakerMuteReverse:null,//喇叭非静音  false为反向   true正向 
  },
  getters: {
    getDeviceInfo(state) {
      return state.deviceInfo;
    },
    getBleStatus(state) {
      return state.bleStatus;
    },
    getSystemInfo(state) {
      return state.systemInfo;
    },
    getCharactValueChangeRes(state) {
      return state.charactValueChangeRes;
    },
    getMasterVolume(state){
      return state.masterVolume;
    }
  },
  mutations: {
    setBleSatuts(state, data) {
      state.bleStatus = data;
    },
    setDeviceInfo(state, data) {
      state.deviceInfo = data;
    },
    setSystemInfo(state, data) {
      state.systemInfo = data;
    },
    setCharactValueChangeRes(state, data) {
      state.charactValueChangeRes = data;
    },
    //模式
    setModeSelection(state, data) {
      state.modeSelection = data;
    },
    // 音源
    setSourceSelection(state, data) {
      state.sourceSelection = data;
    },
    //音效
    setSoundChoice(state, data) {
      state.SoundChoice = data;
    },
    //音场
    setSoundField(state, data) {
      state.soundField = data;
    },
    // 总音量
    setMasterVolume(state, data) {
      state.masterVolume = data;
    },
    // 降噪
    setValDenoise(state, data) {
      state.ValDenoise = data;
    },
    //原车音源
    setOriginalCarAudio(state, data) {
    
      state.originalCarAudio = data;
    },
    // hicar音源
    setHicarCarAudio(state, data) {
      state.HicarCarAudio = data;
    },
    //aux音源
    setAUXCarAudio(state, data) {
      state.AUXCarAudio = data;
    },
    // USB音源
    setUSBCarAudio(state, data) {
      state.USBCarAudio = data;
    },
    // 声场前后
    setsoundFieldback(state, data) {
      state.soundFieldback = data;
    },
    // 左右
    stesoundFieldLeftRight(state, data) {
      state.soundFieldLeftRight = data;
    },
    //喇叭设置 前左
    setIc_hornActive(state, data) {
      state.ic_hornActive = data;
    },
    //喇叭设置 前右
    setIc_beforeActive(state, data) {
      state.ic_beforeActive = data;
    },
    //喇叭设置 后左
    setIc_hornActiveTow(state, data) {
      state.ic_hornActiveTow = data;
    },
    //喇叭设置 后右
    setIc_beforeActiveTow(state, data) {
      state.ic_beforeActiveTow = data;
    },
    setData(state, obj) {
   
      for (let key in obj) {
        // eslint-disable-next-line no-prototype-builtins
        if (obj.hasOwnProperty(key)) {
          state[key] = obj[key];
        }
      }
    },
  },
  actions: {
    setBleSatuts(context, data) {
      context.commit('setBleSatuts', data);
    },
    setDeviceInfo(context, data) {
      context.commit('setDeviceInfo', data);
    },
    setSystemInfo(context, data) {
      context.commit('setSystemInfo', data);
    },
    setCharactValueChangeRes(context, data) {
      context.commit('setCharactValueChangeRes', data);
    },
     // 总音量
     setMasterVolumeAction(context, data) {
      context.commit('setMasterVolume', data);
  
    },
  }
}

export default ble;